package com.yx1996.test.day03;


import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.Test;
import org.springframework.jdbc.core.JdbcTemplate;


/**
 * 演示spring  jdbc模版(与dbUtils类似)
 */
public class Demo1 {

    @Test
    public void fun1() throws Exception {
        //准备连接池
        ComboPooledDataSource comboPool = new ComboPooledDataSource();
        comboPool.setDriverClass("com.mysql.jdbc.Driver");
        comboPool.setJdbcUrl("jdbc:mysql:///haha?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT");
        comboPool.setUser("root");
        comboPool.setPassword("");
        //创建jdbc模版对象
        JdbcTemplate jt = new JdbcTemplate(comboPool);
        //书写sql语句
        String sql = "insert into user values(null,'斩杀')";
        jt.update(sql);
    }
}
